// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    }, //节目编辑
    {
      path: '/programEditor',
      component: '../layouts/BlankLayout',
      authority: ['admin', 'user'],
      routes: [
        {
          name: 'edit',
          path: '/programEditor',
          component: './Program/edit',
        },
      ],
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          authority: ['admin', 'user'],
          routes: [
            {
              // name: '403',
              // icon: 'smile',
              path: '/403',
              component: './403',
              hidden: true,
            },
            {
              // name: '500',
              // icon: 'smile',
              path: '/500',
              component: './500',
              hidden: true,
            }, // {
            //   path: '/',
            //   redirect: '/welcome',
            // },
            // {
            //   path: '/welcome',
            //   name: 'welcome',
            //   icon: 'smile',
            //   component: './Welcome',
            // },
            // {
            //   path: '/admin',
            //   name: 'admin',
            //   icon: 'crown',
            //   component: './Admin',
            //   authority: ['admin'],
            //   routes: [
            //     {
            //       path: '/admin/sub-page',
            //       name: 'sub-page',
            //       icon: 'smile',
            //       component: './Welcome',
            //       authority: ['admin'],
            //     },
            //   ],
            // },
            {
              name: 'home',
              icon: 'home',
              path: '/',
              component: './Dashboard/DashboardAnalysis',
              authority: ['index'],
            },
            {
              path: '/material',
              name: 'materialManagement',
              icon: 'picture',
              authority: ['material'],
              routes: [
                {
                  path: '/material/list',
                  name: 'list',
                  className: 'list',
                  component: './Material/index',
                  authority: ['material:list'],
                },
                {
                  component: './404',
                },
              ],
            },
            {
              path: '/program',
              name: 'programManagement',
              icon: 'profile',
              authority: ['program'],
              routes: [
                {
                  name: 'list',
                  path: '/program/list',
                  className: 'list',
                  component: './Program/index',
                  authority: ['program:list'],
                },
                {
                  name: 'noticeList',
                  path: '/program/noticeList',
                  className: 'noticeList',
                  component: './Program/noticeList',
                  authority: ['program:list'],
                },
                {
                  path: '/program/noticeList/new',
                  component: './program/createNotice',
                  hidden: true,
                },
                {
                  component: './404',
                },
              ],
            },
            {
              path: '/plan',
              name: 'planManagement',
              icon: 'CalendarOutlined',
              authority: ['plan'],
              routes: [
                {
                  name: 'list',
                  path: '/plan/list',
                  className: 'list',
                  component: './Plan/index',
                  authority: ['plan:list'],
                },
                {
                  name: 'review',
                  path: '/plan/review',
                  className: 'review',
                  component: './Plan/review',
                  authority: ['plan:audit'],
                },
                {
                  path: '/plan/list/new',
                  component: './Plan/createPlan',
                  hidden: true,
                },
                {
                  path: '/plan/list/equipment',
                  component: './Plan/equipment',
                  hidden: true,
                },
                {
                  component: './404',
                },
              ],
            }, // {
            //   path: '/template',
            //   name: 'templateManagement',
            //   icon: 'SnippetsOutlined',
            //   routes: [
            //     {
            //       name: 'list',
            //       path: '/template/list',
            //       className: 'list',
            //       component: './Template/index',
            //     },
            //   ],
            // },
            // {
            //   path: '/data',
            //   name: 'dataManagement',
            //   icon: 'DatabaseOutlined',
            //   routes: [
            //     {
            //       name: 'list',
            //       path: '/data/list',
            //       className: 'list',
            //       component: './Data/index',
            //     },
            //     {
            //       name: 'property',
            //       path: '/data/property',
            //       className: 'property',
            //       component: './Data/property',
            //     },
            //   ],
            // },
            {
              path: '/equipment',
              name: 'equipmentManagement',
              icon: 'TabletOutlined',
              authority: ['device'],
              routes: [
                {
                  name: 'list',
                  path: '/equipment/list',
                  className: 'list',
                  component: './Equipment/index',
                  authority: ['device:list'],
                },
                {
                  name: 'groupList',
                  path: '/equipment/groupList',
                  className: 'groupList',
                  component: './Equipment/groupList',
                  authority: ['device:group'],
                },
                {
                  component: './404',
                },
              ],
            },
            {
              path: '/system',
              name: 'systemManagement',
              icon: 'setting',
              authority: ['system'],
              routes: [
                {
                  name: 'user',
                  path: '/system/user',
                  className: 'user',
                  component: './System/user',
                  authority: ['system:user'],
                },
                {
                  name: 'role',
                  path: '/system/role',
                  className: 'role',
                  component: './System/role',
                  authority: ['system:role'],
                },
                {
                  name: 'organization',
                  path: '/system/organization',
                  className: 'organization',
                  component: './System/organization',
                  authority: ['system:org'],
                },
                {
                  name: 'tag',
                  path: '/system/tag',
                  className: 'tag',
                  component: './System/tag',
                  authority: ['system:tag'],
                },
                {
                  name: 'publish',
                  path: '/system/publish',
                  className: 'publish',
                  component: './System/publish',
                  authority: ['system:publish_time_setup'],
                },
                {
                  name: 'update',
                  path: '/system/update',
                  className: 'update',
                  component: './System/update',
                  authority: ['system:apk_version'],
                },
                {
                  name: 'auth',
                  path: '/system/auth',
                  className: 'auth',
                  component: './System/auth',
                  authority: ['system:deviceAuth'],
                },
                {
                  name: 'orgOrder',
                  path: '/system/orgOrder',
                  className: 'orgOrder',
                  component: './System/orgOrder',
                  authority: ['system:org_order'],
                },
                {
                  name: 'log',
                  path: '/system/log',
                  className: 'log',
                  component: './System/log',
                  authority: ['system:log'],
                },
                {
                  component: './404',
                },
              ],
            },
            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  externals: {},
});
